<!--医技科室-->
<template slot-scope="props">
	<section>
		<el-form :inline="true" :model="formInline" class="demo-form-inline" size="medium">

			<el-form-item label="科室名称">
				<el-input class="inline-input" @input="queryAll()" v-model="formInline.dmmc"
				 placeholder="请输入内容"></el-input>
			</el-form-item>
			<el-form-item>
				<el-button type="primary" @click="queryAll()">新增</el-button>
			</el-form-item>

			<el-table :data="tableData" border  height="400px">
				<el-table-column prop="kbxh" label="序号">
					<template slot-scope="scope">
						<el-input v-model="scope.row.kbxh" placeholder="请输入" ></el-input>
					</template>
				</el-table-column>
				<el-table-column prop="dm" label="科别代码">
					<template slot-scope="scope">
						<el-input v-model.trim="scope.row.dm" placeholder="请输入"></el-input>
					</template>
				</el-table-column>
				<el-table-column prop="kbjc" label="科别简称" >
					<template slot-scope="scope">
						<el-input v-model.trim="scope.row.kbjc" placeholder="请输入"></el-input>
					</template>
				</el-table-column>
				<el-table-column prop="dmmc" label="科室名称">
					<template slot-scope="scope">
						<el-input v-model="scope.row.dmmc" placeholder="请输入" ></el-input>
					</template>
				</el-table-column>
				<el-table-column prop="kmdm" label="科目代码" >
					<template slot-scope="scope">
						<el-input v-model="scope.row.kmdm" placeholder="请输入" @keyup.32.native="eee(scope.$index,scope.row.date)"></el-input>
					</template>
				</el-table-column>
				<el-table-column prop="kmmc" label="科目名称" >
					<template slot-scope="scope">
						<el-input v-model="scope.row.kmmc" placeholder="请输入" ></el-input>
					</template>
				</el-table-column>
				<el-table-column prop="bz" label="是否停用">
					<template slot-scope="scope">
						<el-switch v-model="scope.row.bz" active-value="1" inactive-value="0" active-text="启" inactive-text="停"
						 active-color="#13ce66" inactive-color="#ff4949" >
						</el-switch>
					</template>
				</el-table-column>
				<el-table-column label="操作" width="180">
					<template slot-scope="scope">
						 <el-button size="mini" @click="update(scope.row)">修改</el-button> 
						<el-button size="mini" type="danger" @click="handleDelete(scope.row)">删除</el-button>
					</template>
				</el-table-column>
			</el-table>
		</el-form>
		<template>
			<template><medical-subjects :show1.sync="show1" ref="dialogtree" :msg.sync="indexs" /></template>
		</template>
	</section>
</template>

<script>
	import {
		GetMedicalLaboratory,
		UpdateMedicalLaboratory
	} from "@/api";
	import departmentDictionary from '../../components/dialog/departmentdictionary'
	import PagingToolbar from '../../components/toolbar/paging';
	import MedicalSubjects from '../../components/dialog/medicalSubjects';
	export default {
		components: {
			MedicalSubjects,
			'department-dictionary': departmentDictionary
		},
		data() {
			return {
				show1: false,
				indexs: 0,
				restaurants: [],
				formInline: {
					user: '',
					region: ''
				},
				tableData: [],
				
			}
		},
		methods: {
			eee(index, res) {
				this.indexs = index
				this.show1 = true;
			},
			bbb() {
				this.$refs.dialogtree.dialogOpen();
			},

			queryAll(condition) {
				GetMedicalLaboratory(this.formInline).then(res => {
					this.tableData = res.data.data
				})
			},
			fatherMethod(res, index) {
				
				this.tableData[index].kmdm = res.dm
				this.tableData[index].kmmc = res.dmmc
				this.show1 = false;
			},
			handleDelete(row) {
				this.$confirm('此操作将永久删除此人员, 是否继续?', '提示', {
					confirmButtonText: '确定',
					cancelButtonText: '取消',
					type: 'warning'
				}).then(() => {

					this.$message({
						type: 'success',
						message: '删除成功!'
					});
				}).catch(() => {
					this.$message({
						type: 'info',
						message: '已取消删除'
					});
				});
			},
			update(row) {
			
				this.$confirm('确定要修改此项吗, 是否继续?', '提示', {
					confirmButtonText: '确定',
					cancelButtonText: '取消',
					type: 'warning'
				}).then(() => {
					UpdateMedicalLaboratory(row).then(res =>{
						if (res.data.code === 0) {
							this.$message({
								type: 'success',
								message: '修改成功!'
							});
						}else{
							this.$message({
								type: 'error',
								message: '修改失败请联系管理员!'
							});
						}
						this.queryAll();
					})
				
				}).catch(() => {
					this.$message({
						type: 'info',
						message: '已取消修改'
					});
					this.queryAll();
				});

			}

		},
		mounted() {
			this.queryAll();
		}
	};
</script>

<style>
	.el-select .el-input {
		width: 130px;
	}

	.input-with-select .el-input-group__prepend {
		background-color: #fff;
	}

	.el-dropdown-link {
		cursor: pointer;

	}

	.el-icon-arrow-down {
		font-size: 12px;
	}
</style>
